package com.demo.datastructure.reorder.selectorSort;

/**
 * @description:
 * @author: ljr
 * @time: 2021/5/7 21:30
 */
public class MySelectorSort3 {


    public static void selectorSort(int[] args, int n){
        for(int i = 0; i < n; i++){
            int min = args[i];

            boolean flag = true;
            for(int c = i+1; c < n; c++){
                if(min > args[c]){
                    int val = args[c];
                    args[c] = min;
                    min = val;
                    flag = false;
                }
            }
            if(flag){
                break;
            }else{
                args[i] = min;
            }
        }
    }

    public static void main(String[] args) {
        int[] nums = new int[]{4,5,6,3,2,1};
        MySelectorSort3.selectorSort(nums,nums.length);
        for(int num : nums){
            System.out.println(num);
        }
    }
}
